using System;
using System.Windows;
using System.Windows.Navigation;
using Columbus.Tests.Features.Pages;

namespace Columbus.Tests.Features
{
    public static class NavigationApplicationExtensions
    {
        public static TransientStoreMock TransientStoreMock = new TransientStoreMock(new TransientStore());

        public static void StartNormally(this NavigationAppication app)
        {
            app.StatusChanged(null, new NavigationEventArgs(new OneFrameShell(), new Uri("app://app")));
        }

        public static void StartNormallyWithFramelessShell(this NavigationAppication app)
        {
            app.StatusChanged(null, new NavigationEventArgs(new NoFrameShell(), new Uri("app://app")));
        }

        public static void StartNormallyWithNonDefaultFrameName(this NavigationAppication app)
        {
            app.StatusChanged(null, new NavigationEventArgs(new NonDefaultFrameNameShell(), new Uri("app://app")));
        }

        public static void Activate(this NavigationAppication app)
        {
            app.Activated(null, null);
            app.StatusChanged(null, new NavigationEventArgs(new OneFrameShell(), new Uri("app://app")));
        }

        public static void Deactivate(this NavigationAppication app)
        {
            app.StatusChanged(null, new NavigationEventArgs(null, new Uri("app://app")));
        }

        public static NavigationAppication CreateNewAppWithOneNavigatorWithoutLocators(string frameName = Navigator.DefaultNavigationFrameName)
        {
            return new NavigationAppication(new[] { new Navigator(x => null, x => null, frameName) }, TransientStoreMock);
        }

        public static NavigationAppication CreateNewAppWithOneNavigatorWithViewLocator(Func<string, FrameworkElement> viewLocator, string frameName = Navigator.DefaultNavigationFrameName)
        {
            return new NavigationAppication(new[] { new Navigator(x => null, viewLocator, frameName) }, TransientStoreMock);
        }

        public static NavigationAppication CreateNewAppWithOneNavigator(this INavigator navigator)
        {
            return new NavigationAppication(new[] { navigator }, TransientStoreMock);
        }
    }
}